package com.ehome.poct.core.dao.mybatis;

import com.ehome.mybatisplus.support.AbstractCrudRepository;
import com.ehome.poct.core.api.dto.check.CheckItemDTO;
import com.ehome.poct.core.api.dto.check.CheckItemIndicatorDTO;
import com.ehome.poct.core.dao.entity.check.CheckItemIndicatorDO;
import com.ehome.poct.core.dao.mapping.CheckItemIndicatorRepositoryMapping;
import com.ehome.poct.core.dao.mybatis.mapper.CheckItemIndicatorMapper;
import com.ehome.poct.core.repository.CheckItemIndicatorRepository;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 检测项目条目指标RepositoryImpl
 *
 * @author muqiu
 * @Date 2022-03-19 15:31
 */
@Repository
@AllArgsConstructor
public class CheckItemIndicatorRepositoryImpl extends AbstractCrudRepository<CheckItemIndicatorDO, CheckItemIndicatorDTO> implements CheckItemIndicatorRepository {
    private final CheckItemIndicatorMapper checkItemIndicatorMapper;
    private final CheckItemIndicatorRepositoryMapping mapping;

    @Override
    @Cacheable(value = "check:blood:indicators")
    public List<CheckItemIndicatorDTO> findByType(Integer type){
        return mapping.targetToSource(checkItemIndicatorMapper.findByType(type));
    }

    @Override
    public List<CheckItemDTO> selectByParam(Integer projectCode, Integer ageType) {
        return checkItemIndicatorMapper.selectByParam(projectCode, ageType);
    }
}
